package beans;

import java.io.*;
import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class HMConfig {
	
	private String city;
	private String state;
	private String activity;
	private int[] nusers;
	private int[] ntracks;
	private int population;
	private double north;
	private double south;
	private double east;
	private double west;
	
	public HMConfig(String city, String state, String activity, int[] nusers, int[] ntracks, int population,
			double north, double south, double east, double west) {
		this.city = city;
		this.state = state;
		this.activity = activity;
		
		this.nusers = nusers;
		this.ntracks = ntracks;
		this.population = population;
		
		this.north = north;
		this.south = south;
		this.east = east;
		this.west = west;
	}
	
	public String toString() {
		
		StringBuffer metaB = new StringBuffer();
	    for(int i=0; i<nusers.length;i++) {
	    	metaB.append("\n"+nusers[i]);
	    	metaB.append(","+ntracks[i]);
	    }
	    String meta = metaB.toString().substring(1);
		
		return city + " (" + state + "), " + activity + "\n" + meta + "\n" + 
		"bbox = (" + north + "," + south + "," + west + ","+ east + ")\n";
			   
	}

	public String getCity() {
		return city;
	}

	public String getState() {
		return state;
	}

	public String getActivity() {
		return activity;
	}

	public int getNusers(int i) {
		return nusers[i];
	}

	public int getNtracks(int i) {
		return ntracks[i];
	}
	
	public int getPopulation() {
		return population;
	}

	public double getNorth() {
		return north;
	}

	public double getSouth() {
		return south;
	}

	public double getEast() {
		return east;
	}

	public double getWest() {
		return west;
	}
	
	public String getDir() {
		String url = "";
		try {
			//url = URLEncoder.encode(city+"__"+state+"__"+activity,"UTF-8");
			
			URI u = new URI("http","x.com","/"+city+"__"+state+"__"+activity,"");
			url = u.toASCIIString();
			url = url.substring("http://x.com/".length(),url.length()-1);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return url;
	}
	
	
	public static void main(String[] args) throws Exception {
		
		HMConfig hmc = new HMConfig("Cazz Forlì", "IT", "Running", null, null, 0,
				0, 0, 0, 0);
		System.out.println(hmc.getDir());
	}
}
